package cn.changeforyou.web.plugin.page.config;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.plugin.Interceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;

/**
 * mp分页配置
 *
 * @author XWY
 */
@Configuration
@Slf4j
public class MybatisPlusPaginationInterceptorConfig {
    @Bean
    @Conditional(FindMybatisPlusCondition.class)
    public Interceptor paginationInterceptor() {
        MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
        PaginationInnerInterceptor paginationInterceptor = new PaginationInnerInterceptor();
        mybatisPlusInterceptor.addInnerInterceptor(paginationInterceptor);
        log.info("mybatis plus's PaginationInterceptor config ok!");
        return mybatisPlusInterceptor;
    }
}
